package abstractfactory

import (
	"fmt"
	"time"
)

// aws计算资源
type AwsCompute struct {
	instanceID   string
	instanceType string
}

func (r *AwsCompute) Start() string {
	r.instanceID = fmt.Sprintf("i-%x", time.Now().Unix())
	fmt.Printf("aws compute start %s\n", r.instanceType)
	return "aws::" + r.instanceID
}

func (r *AwsCompute) Stop() error {
	fmt.Printf("aws compute stop %s\n", r.instanceID)
	return nil
}

func (r *AwsCompute) GetInstanceType() string {
	return "aws::" + r.instanceType
}

// aws存储资源
type AwsStorage struct {
	bucketName string
}

func (r *AwsStorage) Upload(file string) error {
	fmt.Printf("aws storage upload %s to %s\n", file, r.bucketName)
	return nil
}

func (r *AwsStorage) Download(file string) error {
	fmt.Printf("aws storage download %s from %s\n", file, r.bucketName)
	return nil
}

func (r *AwsStorage) GetBucketName() string {
	return "aws::" + r.bucketName
}

// aws网络资源
type AwsNetwork struct {
	loadBalancerName string
}

func (r *AwsNetwork) CreateLoadBalancer() string {
	r.loadBalancerName = fmt.Sprintf("lb-%x", time.Now().Unix())
	fmt.Printf("aws network create load balancer %s\n", r.loadBalancerName)
	return r.loadBalancerName
}

func (r *AwsNetwork) GetLoadBalancerName() string {
	return "aws::" + r.loadBalancerName
}
